package me.sunpeng.design.prototype.deepclone;

import java.io.Serial;
import java.io.Serializable;

/**
 * @author sp
 */
public class DeepCloneableTarget implements Serializable ,Cloneable{


    @Serial
    private static final long serialVersionUID = 6651803684574927797L;

    private String cloneName;

    private String cloneClass;

    /**
     * 构造器
     * */
    public DeepCloneableTarget(String cloneName,String cloneClass){
        this.cloneName = cloneName;
        this.cloneClass = cloneClass;
    }

    /**
     * 因为该类的属性，都是String，因此这里使用默认的clone完成即可
     * */
    @Override
    public DeepCloneableTarget clone() {
        try {
            // TODO: 复制此处的可变状态，这样此克隆就不能更改初始克隆的内部项
            return (DeepCloneableTarget) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new AssertionError();
        }
    }
}
